<!DOCTYPE html>
<html class="um landscape min-width-240px min-width-320px min-width-480px min-width-768px min-width-1024px">
<head>
<title></title>
<meta charset="utf-8">
<meta name="viewport" content="target-densitydpi=device-dpi, width=device-width, initial-scale=1, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
<link rel="stylesheet" href="css/project/ui-res-v3.css">
<link rel="stylesheet" href="css/project/ui-input-v3.css">
<link rel="stylesheet" href="css/project/ui-color-v3.css">
<link rel="stylesheet" href="css/project/style.css">
<link rel="stylesheet" href="css/ui-base.css">
<link rel="stylesheet" href="css/ui-img.css?v=202022">
<link rel="stylesheet" href="css/ui-box.css?v=202022">
<link rel="stylesheet" href="css/ui-color.css?v=202022">
<link rel="stylesheet" href="css/lbbbase.css">
<link rel="stylesheet" href="css/zv_common.css">
<style>
    .center{
        margin: 0 auto;
    }
    .w60{width:5.0em;}
    .E5E3E0{background-color:#E5E3E0;}
    .border{
        border: 1px solid #D0CCC7;
    }
    .mb3{margin-bottom:.3em;}
    .res{
        background-image:url('images/b-arr.png');
    }
    .calc-img{
        background-image:url('images/calc.png');
    }
    input[type="radio"]:checked + div > div.rdi-icon {
        background-color: transparent;
        background-image: url(images/icon_checked.png);
    }
    input[type=radio]+div>div.rdi-icon {
        background-color: transparent;
        background-image: url(images/icon_uncheck.png);
    }
    
    input[type="radio"]:checked + div.rdi {
        box-shadow:inset 0 1px 4px rgba(0,0,0,0.6);
    }
    .uhide {
        display: none !important;
    }
    

</style>
</head>
<body class="um-vp c-wh" ontouchstart>
<div id="page_0" class="up ub ub-ver" tabindex="0">
   
    <!-- 内容 -->
    <div id="content" class="content mt5 mb5">
        
        <div class="mt12 fs9" >
            <div class="ub uc-a1 tx-c wtp98 lh10 center c2 border mb3">
                <div class="w60 E5E3E0 uinn5 c2">申请人</div>
                <div class="tx-l uinn5" id="cnName"></div>
            </div>
            <div class="ub uc-a1 tx-c wtp98 lh10 center c2 border mb3" >
                <div class="w60 E5E3E0 uinn5 ">申请部门</div>
                <div class="tx-l uinn5" id="deptName" >外航服务中心</div>
            </div>
            <div class="ub uc-a1 tx-c wtp98 lh10 center c2 border mb3" >
                <div class="w60 E5E3E0 uinn5 ">用工类别</div>
                <div class="ub-f1 ub uba  b-wh  sel noboder">
                    <div class="tx-l uinn5 ub-f1 ut-s" id="empType" contenteditable="true"></div>
                    <div class="b-gra  umw2 ub ub-pc ub-ac">
                        <div class="ub-img umw1 umh1 res"></div>
                    </div>
                    <select name="Carrier" selectedindex="0" id="sel_empType" onchange="zy_selectmenu(this.id)">
                            <option value="MU">劳务派遣人员</option>
                            <option value="FM">合同制—结构薪酬员工</option>
                            <option value="KN">实习生</option>
                   </select>
                </div>
            </div>
            <!---------->
            <div class="ub uc-a1 tx-c wtp98 lh10 center c2 border mb3" >
                <div class="w60 E5E3E0 uinn5 ">申请日期</div>
                <div class="tx-l uinn5" id="applyDate" >2016-07-01</div>
            </div>
            <div class="ub uc-a1 tx-c wtp98 lh10 center c2 border mb3" >
                <div class="w60 E5E3E0 uinn5 ">参加<br><div class="mb3"></div>工作时间</div>
                <div class="ub uinn5 mt5 ub-f1" style="width: 100%;">
                    <div class="tx-l ub-f1" id="startWorkDate" onclick="checked_day(this.id)"><span class="c25">请选择时间</span></div>
                    <div class="ub-img calc-img w11" ></div>
                </div>
            </div>
            <div class="ub uc-a1 tx-c wtp98 lh10 center c2 border mb3" >
                <div class="w60 E5E3E0 uinn5 ">进入<br><div class="mb3"></div>公司时间</div>
                <div class="ub uinn5 mt5 ub-f1" style="width: 100%;">
                    <div class="tx-l ub-f1" id="enterCompanyDate" onclick="checked_day(this.id)"><span class="c25">请选择时间</span></div>
                    <div class="ub-img calc-img w11" ></div>
                </div>
            </div>
            <!-----申请类别----->
            <div class="ub uc-a1 tx-c wtp98 lh10 center c2 border mb3" >
                <div class="w60 E5E3E0 uinn5 ">申请类别<span class="fs12 fb t-red">*</span></div>
                <div class="ub-f1 ub uba  b-wh  sel noboder">
                    <div class="tx-l uinn5 ub-f1 ut-s" id="applyType"></div>
                    <div class="b-gra  umw2 ub ub-pc ub-ac">
                        <div class="ub-img umw1 umh1 res"></div>
                    </div>
                    <select name="Carrier" selectedindex="0" id="sel_applyType" onchange="zy_selectmenu(this.id)">
                            <option value="TX">调休</option>
                            <option value="NJ">年假</option>
                            <option value="BJ">病假</option>
                            <option value="SJ">事假</option>
                            <!--option value="FM">异地任职法定假日及公休日离开工作地备案</option>
                            <option value="KN">法定假日及公休日因私出国（境）</option>
                            <option value="MU">其他假期类型</option>
                            <option value="FM">因公外出备案</option-->
                     </select>
                </div>
            </div>
            <!---------->
             <div class="ub uc-a1 tx-c wtp98 lh10 center c2 border mb3" >
                <div class="w60 E5E3E0 uinn5 ">申请理由<span class="fs12 fb t-red">*</span></div>
                <textarea class="tx-l ub ub-f1 noboder " id="applyReason"  placeholder="请填写申请理由" style="resize:none;" ></textarea>
            </div>
            <!--开始时间-------->
            <div class="ub tx-c wtp98 lh10 mb3 center">
                <div class="ub ub-f1 uc-a1 tx-c wtp68 c2 border" >
                    <div class="w60 E5E3E0 uinn5 c2">开始时间<span class="fs12 fb t-red">*</span></div>
                    <div class="ub uinn5 ub-f1" >
                    <div class="tx-l ub-f1" id="startDate" onclick="checkedDay(this.id)"><span class="c25">请选择时间</span></div>
                    <div class="ub-img calc-img w10" ></div>
                </div>
                </div>
                <div class="ub-f1 ub b-wh sel uc-a1 border ml2">
                    <div class="tx-l uinn5 ub-f1 ut-s" id="startTime"></div>
                    <div class="b-gra  umw2 ub ub-pc ub-ac">
                        <div class="ub-img umw1 umh1 res"></div>
                    </div>
                    <select name="Carrier" selectedindex="0" id="time_start" onchange="zy_selectmenu(this.id);calcTime();">
                            <option value="08:30">08:30</option>
                            <option value="09:00">09:00</option>
                            <option value="09:30">09:30</option>
                            <option value="10:00">10:00</option>
                            <option value="10:30">10:30</option>
                            <option value="11:00">11:00</option>
                            <option value="11:30">11:30</option>
                            <option value="12:00">12:00</option>
                            <option value="12:30">12:30</option>
                            <option value="13:00">13:00</option>
                            <option value="13:30">13:30</option>
                            <option value="14:00">14:00</option>
                            <option value="14:30">14:30</option>
                            <option value="15:00">15:00</option>
                            <option value="15:30">15:30</option>
                            <option value="16:00">16:00</option>
                            <option value="16:30">16:30</option>
                            <option value="17:00">17:00</option>
                     </select>
                </div>
            </div>
            <!--结束时间-------->
            <div class="ub tx-c wtp98 lh10 mb3 center">
                <div class="ub ub-f1 uc-a1 tx-c wtp68 c2 border" >
                    <div class="w60 E5E3E0 uinn5 c2">结束时间<span class="fs12 fb t-red">*</span></div>
                    <div class="ub uinn5 ub-f1" >
                    <div class="tx-l ub-f1" id="endDate" onclick="checkedDay(this.id)"><span class="c25">请选择时间</span></div>
                    <div class="ub-img calc-img w10" ></div>
                </div>
                </div>
                <div class="ub-f1 ub b-wh sel uc-a1 border ml2">
                    <div class="tx-l uinn5 ub-f1 ut-s" id="endTime"></div>
                    <div class="b-gra  umw2 ub ub-pc ub-ac">
                        <div class="ub-img umw1 umh1 res"></div>
                    </div>
                    <select name="Carrier" selectedindex="0" id="time_End" onchange="zy_selectmenu(this.id);calcTime();">
                            <option value="08:30">08:30</option>
                            <option value="09:00">09:00</option>
                            <option value="09:30">09:30</option>
                            <option value="10:00">10:00</option>
                            <option value="10:30">10:30</option>
                            <option value="11:00">11:00</option>
                            <option value="11:30">11:30</option>
                            <option value="12:00">12:00</option>
                            <option value="12:30">12:30</option>
                            <option value="13:00">13:00</option>
                            <option value="13:30">13:30</option>
                            <option value="14:00">14:00</option>
                            <option value="14:30">14:30</option>
                            <option value="15:00">15:00</option>
                            <option value="15:30">15:30</option>
                            <option value="16:00">16:00</option>
                            <option value="16:30">16:30</option>
                            <option value="17:00">17:00</option>
                     </select>
                </div>
            </div>
            <!-----总工时 总天数----->
            <div class="ub center mb3 lh10 tx-c wtp98">
                <div class="ub wtp55 uc-a1 c2 border " >
                    <div class="w50 E5E3E0 uinn5 ">总工时<span class="fs12 fb t-red">*</span></div>
                   <input type="text" class="tx-l uinn5 w40" id="totalTime" onkeyup="this.value=this.value.replace(/[^\d{1,}\.\d{1,}|\d{1,}]/g,'')"  onafterpaste="this.value=this.value.replace(/[^\d{1,}\.\d{1,}|\d{1,}]/g,'')" />
                </div>
                <div class="ub wtp40 ub-f1 uc-a1 c2 border ml2" >
                    <div class=" E5E3E0 uinn5 ">总天数<span class="fs12 fb t-red">*</span></div>
                    <input type="text" class="tx-l uinn5 w38" id="totalDay" onkeyup="this.value=this.value.replace(/[^\d{1,}\.\d{1,}|\d{1,}]/g,'')"  onafterpaste="this.value=this.value.replace(/[^\d{1,}\.\d{1,}|\d{1,}]/g,'')" />
                </div>
            </div>
            <!---处理人1---->
            <div class="ub uc-a1 tx-c wtp98 lh10 center c2 border mb3 uhide" id="dealType_one">
                <div class="w60 E5E3E0 uinn5 ">处理人<span class="fs12 fb t-red">*</span></div>
                <div class="ub-f1 ub uba  b-wh  sel noboder">
                    <div class="tx-l uinn5 ub-f1 ut-s" id="nextDealers"></div>
                    <div class="b-gra  umw2 ub ub-pc ub-ac">
                        <div class="ub-img umw1 umh1 res"></div>
                    </div>
                    <select name="Carrier" selectedindex="0" id="sel_nextDealers" onchange="zy_selectmenu(this.id)">
                            
                     </select>
                </div>
            </div>
            <!---处理人2---->
            <div class="ub uc-a1 tx-c wtp98 lh10 center c2 border mb3 uhide" id="dealType_one1">
                <div class="w60 E5E3E0 uinn5 ">处理人<span class="fs12 fb t-red">*</span></div>
                <div class="ub-f1 ub uba b-wh sel noboder ml5">
                    <input type="radio" name="che1" class="uhide"  value="Y"  id="nextDealers0" checked="checked" onclick="alert(1)">
                    <div onclick="zy_for(event)" ontouchstart="zy_touch('btn-act')" class="ub uc-a1 t-bla">
                        <div class="rdi-icon ub-img w15"></div>
                    </div>
                    <div class="ub-f1 ut-s uinn tx-l ulh-sel">李建波</div>
                    
                    <input type="radio" name="che1" class="uhide"  value="W"  id="nextDealers1" >
                    <div onclick="zy_for(event)" ontouchstart="zy_touch('btn-act')" class="ub uc-a1 t-bla">
                        <div class="rdi-icon ub-img w15"></div>
                    </div>
                    <div class="ub-f1 ut-s uinn tx-l ulh-sel">王莺</div>
                </div>
            </div>
            <!---处理人3---->
            <div class="ub uc-a1 wtp98 lh10 center c2 border mb3" id="dealType_multi">
                <div class="w60 E5E3E0 uinn5 tx-c">处理人<span class="fs12 fb t-red">*</span></div>
                <div class="ub-f1  uba b-wh sel noboder ml20 mt6" id="chkOptions">
                    <!---div class="i-check " >  
                       <input type="checkbox" value="0" />  
                       <label class="ub-f1 ut-s uinn tx-l ulh-sel">李建波</label>  
                    </div>  
                    <div class="i-check">  
                       <input type="checkbox" value="0" />  
                       <label class="ub-f1 ut-s uinn tx-l ulh-sel">王莹</label>  
                    </div!--->
                </div>
            </div>
        </div>
        
    </div>
    
</div>
<script src="js/appcan.js"></script>
<script src="js/zy_control.js?v=202022"></script>
<script src="js/zy_click.js?v=202022"></script>
<script src="js/jquery-1.11.1.min.js?v=202022"></script>
<script src="js/main.js"></script>
<script src="js/apply.js?v=202022"></script>
<script>
zy_init();
window.uexOnload = function(type){
    if (!type) {
         exitreturn();
         getApplyInfoFuc(function(json){applyInfo(json);});//1.a)申请人基本信息获取
         getSecondNodeInfoFuc(function(json){secondNodeInfo(json);});//1.获取工作流第一个审批节点上的基本信息
    };
}; 

var applyInfo;
function applyInfo(json)
{
     if(json.status==0)
     {
         var Obj=json.data.leaveApply;
         applyInfo=Obj;
         // submit();
         $("#cnName").text(Obj.cnName);
         $("#deptName").text(Obj.deptName);
         $("#empType").text(Obj.empType);
         $("#applyDate").text(getDates());
         
         // $('#sel_applyType')[0].selectedIndex=0;
         var empType=$("#sel_empType").find("option:selected").text();
        $("#empType").text(empType);
        
        var applyType=$("#sel_applyType").find("option:selected").text();
        $("#applyType").text(applyType); 
        
     }
}

var dealType;
function secondNodeInfo(json)
{
    if(json.status==0)
     {
         dealType=json.data.node.dealType;
         dealType="one";  //test
         if(dealType=="one")
         {
             $("#dealType_one").removeClass("uhide");
             $("#dealType_multi").addClass("uhide");
             //处理人
             var nodeUsersArr=json.data.nodeUsers;
             var len=nodeUsersArr.length;
             for(var i=0;i<len;i++)
             {
                 $("#sel_nextDealers").append("<option value='"+nodeUsersArr[i].userName+"'>"+nodeUsersArr[i].fullUserName+"</option>"); 
                 
             }
             var nextDealers=$("#sel_nextDealers").find("option:selected").text();
             $("#nextDealers").text(nextDealers);
         }else if(dealType=="multi")
         {
             $("#dealType_multi").removeClass("uhide");
             //处理人
             var nodeUsersArr=json.data.nodeUsers;
             var len=nodeUsersArr.length;
             for(var i=0;i<len;i++)
             {
                 $("#chkOptions").append("<div class='i-check' ><input type='checkbox' name='category' value='"+nodeUsersArr[i].userName+"' /><label class='ub-f1 ut-s uinn tx-l ulh-sel'>"+nodeUsersArr[i].fullUserName.split("\\")[1]+"</label></div>");
             }
             // var nextDealers=$("#sel_nextDealers").find("option:selected").text();
             // $("#nextDealers").text(nextDealers);
         }else if(dealType=="all")
         {
             $("#dealType_one").addClass("uhide");
             $("#dealType_multi").addClass("uhide");
         }
         
     }
}


/**
  * 检查哪些项被选中
  */
var nextDealerstr='';
function checkedOptions(){
    nextDealerstr='';
    if(dealType=="one")
    {
        nextDealerstr=$("#sel_nextDealers").find("option:selected").val();
    }
    else{
        var items = document.getElementsByName("category");
        if(items.length==0)
        {
            return;
        }
        for (var i = 0; i < items.length; ++i)
        {
            if (items[i].checked)
            {
                nextDealerstr+=items[i].value+",";
            }
        }
        nextDealerstr=nextDealerstr.substr(0,nextDealerstr.length-1);
    }
    
}
function submit(){
    
    /***检查必填信息 */
    checkedOptions();
    // alert("nextDealerstr")
    var applyReason=$("#applyReason").val();
    var startDate=$("#startDate").text();
    var endDate=$("#endDate").text();
    var totalTime=$("#totalTime").val();
    var totalDay=$("#totalDay").val();
    if(applyReason==''||totalTime==''||totalDay==''||startDate=='请选择时间'||endDate=='请选择时间'||nextDealerstr=='')
    {
           appcan.window.alert({
            title:'提示',
            content:'请完善*必填信息',
            buttons:'确定'
         });
         return;
    }
    
    var applyDate=getDates();
    // var applyReason=$("#applyReason").val();
    var applyType=$("#applyType").text();
    var cnName=$("#cnName").text();
    var deptName=$("#deptName").text();
    var empType=$("#empType").text();
    // var endDate=$("#endDate").text();
    var endTime=$("#endTime").text();
    var enterCompanyDate=$("#enterCompanyDate").text();
    var nextDealers=nextDealerstr;
    // var startDate=$("#startDate").text();
    var startTime=$("#startTime").text();
    var startWorkDate=$("#startWorkDate").text();
    // var totalDay=$("#totalDay").text();
    // var totalTime=$("#totalTime").text();
    var userName=applyInfo.userName;
    var accessory=applyInfo.accessory;
    var applyId=applyInfo.applyId;
    var companyCode=applyInfo.companyCode;
    var creatorId=applyInfo.creatorId;
    var creatorName=applyInfo.creatorName;
    var id=applyInfo.id;
    var modifyId=applyInfo.modifyId;
    var modifyName=applyInfo.modifyName;
    var status=applyInfo.status;
    var createTime=null;  //？？？
    var modifyTime=null;  //？？？
    var jsonObj={
            "accessory": accessory,
            "applyDate": applyDate,
            "applyId": applyId,
            "applyReason":applyReason,
            "applyType": applyType,
            "cnName": cnName,
            "companyCode": companyCode,
            "createTime": createTime,
            "creatorId": creatorId,
            "creatorName": creatorName,
            "deptName": deptName,
            "empType": empType,
            "endDate": endDate,
            "endTime":endTime,
            "enterCompanyDate": enterCompanyDate,
            "id": id,
            "modifyId": modifyId,
            "modifyName":modifyName,
            "modifyTime": modifyTime,
            "nextDealers": nextDealers,
            "startDate": startDate,
            "startTime":  startTime,
            "startWorkDate": startWorkDate,
            "status": status,
            "totalDay": totalDay,
            "totalTime": totalTime,
            "userName": userName
        }
        jsonObj=JSON.stringify(jsonObj);
        var jsonstr={"jsonstr":jsonObj};
        doSubmitFuc(jsonstr);
}
function calcTime(){
     // alert((new Date("2016-11-08")-new Date("2016-11-09"))/(24*60*60*1000))
    var starDate=$("#startDate").text();
    var endDate=$("#endDate").text();
    var startTime=$("#startTime").text();
    var endTime=$("#endTime").text();
    // console.log(starDate+" / "+endDate+" / "+startTime+" / "+endTime)
    if(starDate!="请选择时间"&&endDate!="请选择时间"&&startTime!=""&&endTime!="")
    {
        if(starDate>endDate||(starDate==endDate&&parseInt(startTime)>parseInt(endTime))){
               appcan.window.alert({
                title:'提示',
                content:'开始时间应小于结束时间，请选择正确的时间',
                buttons:'确定'
             });
        }else{
            var dt=(new Date(endDate)-new Date(starDate))/(24*60*60*1000)+1;
            if(parseInt(startTime)>=13)
            {
               dt=dt-0.5;
            }
            if(parseInt(endTime)<13)
            {
               dt=dt-0.5;
            }
           $("#totalDay").val(dt);
           $("#totalTime").val(dt*8); 
        }
    }
    
}
/**
 * 时间选择
 */
function checkedDay(id){
        //var date = getNowFormatDate();
        var date=$$(id).innerHTML
        var dateArr = date.split("-");
        uexControl.openDatePicker(dateArr[0],dateArr[1],dateArr[2]);
             uexControl.cbOpenDatePicker = function(opId, dataType, data){
                if (dataType == 1) {
                    var obj = eval('(' + data + ')');
                    var CurrentDate = "";
                    
                   var Year    = obj.year;
                   var Month = obj.month; 
                   var Day = obj.day;
                   CurrentDate += Year + "-"; 
                   if (Month >= 10 ) 
                   { 
                    CurrentDate += Month + "-"; 
                   } 
                   else
                   { 
                    CurrentDate += "0" + Month + "-"; 
                   } 
                   if (Day >= 10 ) 
                   { 
                    CurrentDate += Day ; 
                   } 
                   else
                   { 
                    CurrentDate += "0" + Day ; 
                   } 
                    
                    $$(id).innerHTML = CurrentDate;
                    calcTime();
                }
            }
 }
</script>
</body>
</html>